package se.webbzon.boltzmann.minigame.machine;

import se.webbzon.oschi01.resourceset.ResourceIterator;
import se.webbzon.oschi01.resourceset.ResourceSet;
import se.webbzon.oschi01.textureset.Texture3D;

public class MachinePart {
	
	// The texture iterator of this machine part
	private final ResourceIterator<Texture3D> it;
	
	// The position of the machine part 
	private double x, y;
	
	/*============================================================
	Constructors
	============================================================*/
	
	public MachinePart(ResourceSet<Texture3D> textureSet) {
		this(textureSet,0,0);
	}
	
	public MachinePart(ResourceSet<Texture3D> textureSet, double x, double y) {
		this.it = new ResourceIterator<Texture3D>(textureSet);
		it.setSpeed(1);
		this.x = x;
		this.y = y;
	}
	
	/*============================================================
	Public Methods
	============================================================*/
	
	/** Sets the animation speed of this machine part. **/
	public void setSpeed(double speed) {
		it.setSpeed(speed);
	}
	
	/** Returns the animation speed of this machine part. **/
	public double getSpeed() {
		return it.getSpeed();
	}
	
	/** Returns the texture of this machine part. **/
	public Texture3D getTexture3D() {
		return it.current();
	}
	
	/** Performs an step end action for this machine part. **/
	public void onStepEnd() {
		it.next();
	}

	/** Returns the x-position of this machine part relative to the machine. **/
	public double getX() {
		return x;
	}

	/** Sets the x-position of this machine part relative to the machine. **/
	public void setX(double x) {
		this.x = x;
	}

	/** Returns the y-position of this machine part relative to the machine. **/
	public double getY() {
		return y;
	}

	/** Sets the y-position of this machine part relative to the machine. **/
	public void setY(double y) {
		this.y = y;
	}

}
